<template>
  <div id="app">
    {{mycount}}
    <br>
    <p>当前是 <span style="color: green">{{flag}}</span> 数</p>
    <br>
    {{fullName}}
    <button @click="add({msg:123})">+</button>
    <button @click="des">-</button>
  </div>
</template>

<script>
  import {mapState,mapActions,mapGetters} from "vuex"
  export default {
    name: 'App',
    //仓库中的state数据在组件上最好使用一个计算属性与之对应
    //仓库中的actions mutations在组件上一般都有一个方法与之对应
    computed:{
      // ...mapState({mycount:"count"}),
      // ...mapState(["count"]),
      mycount(){
        return this.$store.state.count
      },
      ...mapGetters(["flag","fullName"])
    },
    methods:{
      ...mapActions(["add","des"])
    }
  }
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
